package com.langChain4j.domain.controller;

import com.base.api.entity.RestResponse;
import com.langChain4j.agent.AgentCoordinator;
import com.langChain4j.domain.controller.vo.ConversationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author linjun
 * @date 2025/9/23 17:08
 * @description
 */
@RestController
@RequestMapping("/api/v1/business/conversation")
@Slf4j
@Api(tags = "智能体对话交互接口")
public class BusinessConversationController {

    @Autowired
    private AgentCoordinator agentCoordinator;

    @PostMapping("/start")
    @ApiOperation("发起对话会话")
    public RestResponse<Object> startConversation(@Valid @RequestBody ConversationVo conversationVo) {
        return RestResponse.<Object>builder()
                .data(agentCoordinator.processQuery(conversationVo.getMessage()))
                .build();
    }
}
